﻿@model IQueryable<USERS.CYT369.COM.MODELS.Articles.Document>
@{
    Layout = "_MyLayout";
    ViewData["Title"] = "所有文章";
}
@section styles{
    <link href="~/css/news/articles.css" rel="stylesheet" />
}
@section scripts{
    <script src="~/js/Common.js"></script>
    <script src="~/js/SystemSetting.js"></script>
    <script src="~/js/news/article-index.js"></script>
}

<div class="easyui-layout" fit="true">
    <div data-options="region:'north',border:false" style="overflow: hidden; padding: 5px; border-bottom: solid 1px #ddd">
        @await Html.PartialAsync("Articles/_ArticleMenuHeader")
        @await Html.PartialAsync("Articles/_ArticleSearchHeader")
    </div>
    <div data-options="region:'west',border:false,split:true" style="width: 180px; border-right: solid 1px #ddd;">
        <ul class="easyui-tree" fit="true" data-options="url:'~/News/GetUserDocCategorys',method:'get'"></ul>
    </div>
    <div data-options="region:'center',border:false">
        <div class="easyui-layout" fit="true">
            <div data-options="region:'center',border:false"  class="min-scrollbar" style="padding:3px">
                <div class="article-list">
                    @if (Model != null)
                    {
                        foreach (var doc in Model)
                        {
                            var preViewUrl = USERS.CYT369.COM.UTILITY.SystemSettingService.Instance.NewsServer;
                            if (doc.Published)
                            {
                                preViewUrl = $"{preViewUrl}/Articles/View/{Base64.ObjectToBase64(new { NID = doc.Id })}.chtml";
                            }
                            else
                            {
                                preViewUrl = $"{preViewUrl}/Articles/PView/{Base64.ObjectToBase64(new { NID = doc.Id, UID = ViewBag.UserID })}.chtml";
                            }
                            <div class="article">
                                <div class="title-panel">
                                    <div class="title"><a target="_blank" href="@preViewUrl">@doc.Title</a></div>
                                    <div class="time">@doc.ChangedTime.ToString("yyyy-MM-dd HH:mm:ss")</div>
                                </div>
                                <div class="summary-panel">@doc.Summary</div>
                                <div class="label-panel">
                                    @switch (doc.ContentSourceID)
                                    {
                                        case 1:
                                            <div class="lebel origin">原创</div>
                                            break;
                                        case 2:
                                            <div class="lebel reprint">转载</div>
                                            break;
                                        case 3:
                                            <div class="lebel translate">翻译</div>
                                            break;
                                    }

                                    @switch (doc.AuditStatusID)
                                    {
                                        case 0:
                                            <div class="lebel audit-draft">草稿</div>
                                            break;
                                        case 1:
                                            <div class="lebel audit-passed">审核通过</div>
                                            break;
                                        case 2:
                                            <div class="lebel audit-failed">审核未通过</div>
                                            break;
                                        case 10:
                                            <div class="lebel audit-audting">正在审核</div>
                                            break;
                                    }
                                    @if (doc.Published)
                                    {
                                        <div class="lebel published">已发布</div>
                                    }
                                    else
                                    {
                                        <div class="lebel not-publish">未发布</div>
                                    }
                                </div>
                                <div class="ops-panel">
                                    <ul class="infos">
                                        <li class="item">阅读 @doc.Read</li>
                                        <li class="item">评论 0</li>
                                        <li class="item">收藏 0</li>
                                    </ul>
                                    <ul class="ops">
                                        <li class="item"><a href="~/News/EditArticle/@Base64.ObjectToBase64(new { NID = doc.Id })">编辑</a></li>
                                        <li class="item"><a href="javascript:DeleteArticle('@Base64.ObjectToBase64(new { NID = doc.Id })')">删除</a></li>
                                    </ul>
                                </div>
                            </div>
                        }
                    }
                </div>

            </div>
            <div data-options="region:'south',border:false" style="height:35px;border-top:solid 1px #ddd">
                <div class="easyui-pagination" data-options="total:@ViewBag.TotalCount,pageSize:@ViewBag.PageRows,pageNumber:@ViewBag.PageNumber,onSelectPage:on_page_change"></div>
            </div>
        </div>
    </div>
</div>
